package com.zbkj.front.controller;

import com.zbkj.common.model.member.UserElectronicInvoiceConfig;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.UserElectronicInvoiceConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/front/userElectronicInvoiceConfig")
@Api(tags = "用户发票设置")
public class UserElectronicInvoiceConfigController {

    @Autowired
    private UserElectronicInvoiceConfigService userElectronicInvoiceConfigService;

    @ApiOperation(value = "新增用户发票设置")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public CommonResult<UserElectronicInvoiceConfig> add(@RequestBody UserElectronicInvoiceConfig userElectronicInvoiceConfig) {
        return CommonResult.success(userElectronicInvoiceConfigService.add(userElectronicInvoiceConfig));
    }

    @ApiOperation(value = "（修改）用户发票设置")
    @RequestMapping(value = "/set", method = RequestMethod.POST)
    public CommonResult<UserElectronicInvoiceConfig> set(@RequestBody UserElectronicInvoiceConfig userElectronicInvoiceConfig) {
        return CommonResult.success(userElectronicInvoiceConfigService.set(userElectronicInvoiceConfig));
    }

    @ApiOperation(value = "设置默认发票")
    @RequestMapping(value = "/set/status/{id}", method = RequestMethod.GET)
    public CommonResult<Integer> setStatus(@PathVariable("id") Integer id) {
        return CommonResult.success(userElectronicInvoiceConfigService.setStatus(id));
    }

    @ApiOperation(value = "获取发票列表")
    @RequestMapping(value = "/getList", method = RequestMethod.POST)
    public CommonResult<List<UserElectronicInvoiceConfig>> getList(@RequestBody UserElectronicInvoiceConfig userElectronicInvoiceConfig) {
        return CommonResult.success(userElectronicInvoiceConfigService.getList(userElectronicInvoiceConfig));
    }

    @ApiOperation(value = "获取指定发票信息")
    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
    public CommonResult<UserElectronicInvoiceConfig> get(@PathVariable("id") Integer id) {
        return CommonResult.success(userElectronicInvoiceConfigService.get(id));
    }

    @ApiOperation(value = "获取默认发票信息")
    @RequestMapping(value = "/get/default", method = RequestMethod.GET)
    public CommonResult<UserElectronicInvoiceConfig> getDefault() {
        return CommonResult.success(userElectronicInvoiceConfigService.getDefault());
    }
}
